<?php
/**
 * Created by PhpStorm.
 * User: hebidu
 * Date: 15/11/18
 * Time: 11:24
 */

namespace Tool\Controller;


use Common\Util\EnvCheck;
use Think\Controller;
use Uclient\Api\UserApi;

class AppController extends Controller{

    function think_ucenter_md5($str, $key = 'ThinkUCenter'){
        return '' === $str ? '' : md5(sha1($str) . $key);
    }
    public function reset(){
        //重置密码为$password
        $default_password = "123456";
        $auth_key = UC_AUTH_KEY;
        $api = D('UcenterMember');
        $map['id'] = array('lt',10);
        $result = $api->where($map)->select();

        if(is_array($result)){
            foreach($result as $vo){
                $map = array('id'=>$vo['id']);
                $data = array(
                    'password'=> $this->think_ucenter_md5($default_password,$auth_key),
                );
                $api->where($map)->save($data);
            }
            echo "重置成功";
        }
        else{
            echo "重置失败";
        }

    }

    public function index(){

        $check = new EnvCheck();
        //Android 链接
        $android_url = "http://app.itboye.com/guangda.apk";
        $ios_url = "";

        $this->assign("url",$android_url);
        $this->assign("is_weixin",0);
        $this->assign("is_iphone",0);

        if($check->isWeixinBrowse()){
            $this->assign("is_weixin",1);
        }

        if($check->isIphone()){
            //IOS 链接
            $this->assign("url",$ios_url);
            $this->assign("is_iphone",1);
        }

        $this->display();
    }

}